//
//  MyTableViewCell.swift
//  studyRxSwiftDemo
//
//  Created by jemi on 2019/12/18.
//  Copyright © 2019 jemi. All rights reserved.
//

import UIKit
import SnapKit

class MyTableViewCell: UITableViewCell {
    
    var nameLabel = UILabel()
    var sexLabel = UILabel()
    var ageLabel = UILabel()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        loadUI()
    }
    
    func setupModel(_ m:My) {
        nameLabel.text = m.name
        sexLabel.text = m.sex
        ageLabel.text = "\(m.age)"
    }
    
    func loadUI(){
        contentView.addSubview(nameLabel)
        nameLabel.snp.makeConstraints { (m) in
            m.leading.equalTo(20)
            m.centerY.equalToSuperview()
            m.height.equalTo(20)
        }
        
        contentView.addSubview(sexLabel)
        sexLabel.snp.makeConstraints { (m) in
            m.centerX.equalToSuperview()
            m.centerY.equalToSuperview()
            m.height.equalTo(20)
        }
        
        contentView.addSubview(ageLabel)
        ageLabel.snp.makeConstraints { (m) in
            m.trailing.equalTo(-20)
            m.centerY.equalToSuperview()
            m.height.equalTo(20)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
